package com.controller.zk;

import com.aliyun.core.annotation.Path;
import com.bean.zk.Power;
import com.dao.zk.PowerDAO;
import com.service.zk.ResourceService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class ResourceController {

    @Resource
    private ResourceService resourceService;

    @RequestMapping("/page/getallpowers")
    @ResponseBody
    public List<Power> getResources() {
        return resourceService.getPowers();
    }

    @RequestMapping("/page/getfanodes")
    @ResponseBody
    public List<Power> get() {
        return resourceService.get();
    }

    @RequestMapping("/page/getpowerbypid/{power_id}")
    @ResponseBody
    public List<Power> getByPid(@PathVariable String power_id) {
        return resourceService.getByPid(power_id);
    }

    /**
     * 更新权限
     * @param power
     * @return
     */
    @RequestMapping("/page/updatepower")
    @ResponseBody
    public int getByPid(Power power) {
        return resourceService.updatePower(power);
    }

    @RequestMapping("/page/reblursel")
    @ResponseBody
    public List<Power> sel(String p_name,String fanode) {
        if (fanode.equals("0")) {
            return resourceService.get();
        }else{
            return resourceService.sel(p_name,fanode);
        }
    }
}
